package com.yy.service.impl;




import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yy.common.Resault;
import com.yy.domain.Bicycle;
import com.yy.dto.BicycleDTO;
import com.yy.mapper.BicycleMapper;
import com.yy.service.BicycleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BicycleServiceImpl implements BicycleService {
    @Autowired
    private BicycleMapper bicycleMapper;

    /**
     * @param bicycleDTO
     * @return
     */
    @Override
    public Resault<List<Bicycle>> queryAllBicycle(BicycleDTO bicycleDTO) {
        PageHelper.startPage(bicycleDTO.getPageNum(),bicycleDTO.getPageSize());
        List<Bicycle> positionVoList=bicycleMapper.selectPositionVoByCondition(bicycleDTO);
        PageInfo<Bicycle> pageInfo=new PageInfo<>(positionVoList);
        Resault<List<Bicycle>> result=new Resault<>(pageInfo.getTotal(),pageInfo.getList());
        return result;
    }

    /**
     * @param
     * @return
     */
    @Override
    public Bicycle getBicycleById(Integer bicycleId) {
        return this.bicycleMapper.selectByPrimaryKey(bicycleId);
    }

    /**
     * @param bicycle
     * @return
     */
    @Override
    public int updateBicycle(Bicycle bicycle) {
        return this.bicycleMapper.updateByPrimaryKeySelective(bicycle);
    }


}
